package com.hugh.dubbo.service.consumer.controller;

import com.alibaba.fastjson.JSON;
import com.hugh.dubbo.service.consumer.service.TestOneService;
import com.hugh.dubbo.service.consumer.service.TestTwoService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @Author: Hugh
 * @Date: 2020/6/14
 */
@Controller
@RequestMapping(value = "api/")
@Slf4j
public class UserController {

    @Autowired
    private TestOneService testOneService;

    @Autowired
    private TestTwoService testTwoService;

    @RequestMapping(value = "test1")
    @ResponseBody
    public Object test1(){
        Object testOne = testOneService.getTestOne("test1");
        log.info("UserController:{}", JSON.toJSON(testOne));
        return testOne;
    }

    @RequestMapping(value = "test2")
    @ResponseBody
    public Object test2(Integer count){
        Object test2 = testTwoService.getTestTwo(count);
        log.info("UserController:{}", JSON.toJSON(test2));
        return test2;
    }
}
